var statuses = {
    0: "Unknown",
    1: "Running",
    2: "Canceled",
    3: "Finished",
    4: "Failed"
}

var databaseGroup = {    0: "None",    1: "A",    2: "B"}

var collection = db.getSiblingDB("ClientDWMaster").SyncLog
var bulk = collection.initializeUnorderedBulkOp();
var myDocuments = collection.find({Status: { $type: 16 }}); 
var ops = 0;     
var startDate = new Date();
myDocuments.forEach( 
	function(item){
		item.Status = statuses[item.Status];
		item.DatabaseGroup = databaseGroup[item.DatabaseGroup];

		bulk.find({ _id: item._id }).replaceOne(item);
		
		if ((++ops %1000) === 0){
			bulk.execute();
			bulk = collection.initializeUnorderedBulkOp();
	   }
	}
)
			
bulk.execute();   
var endDate = new Date();
print("\t\t\t" + collection + "\n\nStartDate: " + startDate + "\nEndDate: " + endDate + "\n\n")
